package com.jiot.controller.order;

import com.zg.cloud.BaseResponse;
import com.zg.cloud.annotation.TokenCheck;
import com.zg.cloud.service.OrderService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import req.order.AddPriceReq;
import req.order.OrderPaymentReq;
import req.order.RenewalInterfaceReq;

import javax.annotation.Resource;
import javax.validation.Valid;

/**
 * @author hushi
 * @date 2020/11/12 15:28
 * @description
 */
@RestController
@RequestMapping("/order/order")
@Api(value = "订单模块")
public class OrderController {

    @Resource
    private OrderService orderService;

    @PostMapping("/renewal/interface")
    @TokenCheck
    @ApiOperation(value = "缴费界面", notes = "order")
    public BaseResponse renewalInterface(@RequestBody @Valid RenewalInterfaceReq renewalInterfaceReq) {
        return new BaseResponse(orderService.renewalInterface(renewalInterfaceReq));
    }

    @PostMapping("/order/payment")
    @TokenCheck
    @ApiOperation(value = "订单缴费", notes = "order")
    public BaseResponse orderPayment(@RequestBody @Valid OrderPaymentReq orderPaymentReq) {
        orderService.orderPayment(orderPaymentReq);
        return new BaseResponse();
    }

    @PostMapping("/check/the/renewal/price")
    @TokenCheck
    @ApiOperation(value = "查询订单价格", notes = "order")
    public BaseResponse checkTheRenewalPrice() {
        return new BaseResponse(orderService.checkTheRenewalPrice());
    }

    @PostMapping("/add/price")
    @TokenCheck
    @ApiOperation(value = "添加订单价格", notes = "order")
    public BaseResponse addPrice(@RequestBody @Valid AddPriceReq addPriceReq) {
        orderService.addPrice(addPriceReq);
        return new BaseResponse();
    }

}
